import { post } from '@/utils/request'

// 拼团一览表
export const getCollageList = async (params) => {
  const url = `/api/admin/collage/get_collage_list?page_size=${params.page_size}&page_num=${params.page_num}`
  const res = await post(url, params)
  return res
}

// 拼团订单
export const getCollageOrderList = async (params) => {
  const url = `/api/admin/collage/get_collage_order_list?page_size=${params.page_size}&page_num=${params.page_num}`
  const res = await post(url, params)
  return res
}

// 查询所有商品列表
export const getAllProducts = async (params) => {
  const url = `/api/admin/product/get_product_list?page_size=${params.page_size}&page_num=${params.page_num}`
  const res = await post(url, params)
  return res
}

// 查询所有优惠券列表
export const getAllCoupon = async (params) => {
  const url = `/api/admin/coupon/get_all_coupon`
  const res = await post(url, params)
  return res
}

// 创建拼团
export const createCollage = async (params) => {
  const res = await post('/api/admin/collage/create', params)
  return res
}

// 编辑拼团
export const updateCollage = async (params) => {
  const res = await post('/api/admin/collage/update', params)
  return res
}

// 获取拼团详情
export const getCollageDetail = async (params) => {
  const url = `/api/admin/collage/detail?id=${params.id}`
  const res = await post(url, params)
  return res
}

// 拼团 上下架
export const updateCollageStatus = async (params) => {
  const url = `/api/admin/collage/update_collage_status`
  const res = await post(url, params)
  return res
}

// 拼团订单 消费记录
export const getCollageByGroupId = async (params) => {
  const url = `/api/admin/collage/get_collage_by_group_id?id=${params.id}`
  const res = await post(url, params)
  return res
}

// 拼团订单 凑团
export const finishCollageByGroupId = async (params) => {
  const url = `/api/admin/collage/finish_collage_by_group_id?id=${params.id}`
  const res = await post(url, params)
  return res
}
